define(['backbone'], function (Backbone) {
	var View = Backbone.View.extend({
		constructor: function(options){
			if(options)this.superview = options.superview;
			Backbone.View.apply(this, arguments);
		},

		events: {
			'click button[data-action=back]': 'goBack'
		},

		show: function() {
		},

		hide: function() {
		},

		goBack: function() {
			window.history.back();
		},

		getClientSize: function() {
			var $window = $(window);
			return {
				clientWidth: $window.width(),
				clientHeight: $window.height()
			}
		}
	});

	var animations = ['slideInLeft', 'slideInRight', 'slideOutLeft', 'slideOutRight', 'slideInUp', 'slideInDown', 'slideOutUp', 'slideOutDown', 'fadeIn', 'fadeOut'];

	//animate
	var animationExtentions = {
		animate: function(name, onFinish){
			var me = this;
			this.$el.addClass('animated ' + name);
			this.$el.one('webkitAnimationEnd MSAnimationEnd animationend', function(){
				me.$el.removeClass('animated ' + name);
				if (onFinish) onFinish();
			});
		}
	}

	//transform animation name array to <name: fn> mapping json object
	animationExtentions = _.foldl(animations, function(memo, animation){
		memo['animate' + animation[0].charAt(0).toUpperCase() + animation.substring(1)] = function(onFinish){
			this.animate(animation, onFinish);
		}
		return memo;
	}, animationExtentions);

	//add to View prototype
	_.extend(View.prototype, animationExtentions);

	return View;
})